<%= javascript_include_tag 'product_show.js' %>

<div id='breadcrumb'>
  <%=  breadcrumb_for_product(@product)%>
</div>
<h1><%=h @product.name %></h1>
<div id='medium_img'>
  <% if @product.image_url%>
    <a href="<%=url_for_file_column(@product, "image_url")%>">
      <%= image_tag url_for_file_column(@product, "image_url","medium"),:class=>'product_img' %>
    </a>
  <% elsif @product.category && @product.abstract_product && @product.abstract_product.image_url %>
    <a href="<%=url_for_file_column(@product.abstract_product, "image_url")%>">
      <%= image_tag url_for_file_column(@product.abstract_product, "image_url","medium"),:class=>'product_img' %>
    </a>
  <% end  %>
</div>
<div id='product_main_info'>
  <table>
    <tr>
      <td>
        <label>类别:</label>
      </td>
      <td>
        <%=h @product.category.name if @product.category %>
      </td>
    </tr>

    <tr>
      <td>
        <label>品牌:</label>
      </td>
      <td>
        <%=h @product.brand.name if @product.brand %>
      </td>
    </tr>

    <tr>
      <td>
        <label>商品名称:</label>
      </td>
      <td>
        <%=h @product.name %>
      </td>
    </tr>

    <tr>
      <td>
        <label>型号:</label>
      </td>
      <td>
        <%=h @product.model %>
      </td>
    </tr>

    <tr>
      <td>
        <label>货号:</label>
      </td>
      <td>
        <%=h @product.sn %>
      </td>
    </tr>

    <tr>
      <td>
        <label>零售价:</label>
      </td>
      <td>
        <span class="yen"><%=@product.retail_price %></span>
      </td>
    </tr>


    <% if @product.properties.count > 0 %>
      <% for p in @product.properties %>
        <tr>
          <td>
            <label>
              <%=p.name%>:
            </label>
          </td>
          <td>
            <%=h p.value %>
          </td>
        </tr>
      <% end %>
    <%end%>

    <tr id="link_button_container">
      <td colspan='2'>
        <a href="javascript:void(0);" onclick="emptyCart();" >加入比较</a>
        <a href="javascript:void(0);" onclick="addToCart(<%=@product.id%>);" >购买</a>
        <input class="item_quantity"  id="item_quantity_on_detail" type="text"  size="1" value="1" />台
      </td>
    </tr>
  </table>

</div>

<div id='product_description_container'>
  <p>
    <h2>产品说明</h2>
  </p>

  <% if @product.abstract_product && @product.abstract_product.description %>
    <%= @product.abstract_product.description %>
  <%end%>

  <%  if @product.description  %>
    <%= @product.description %>
  <%  end %>
</div>


<div class="toolbar">
  <% if admin? %>
    <%= link_to '编辑',[:edit, @category, @product],:class=>'action_edit' -%>
    <% if @product.abstract_product %>
      |
      <a href="/abstract_products/<%=@product.abstract_product.id%>/edit" class="action_edit">编辑母商品</a>
    <%else%>
      |
      <a href="/abstract_products/new?brand_id=<%=@product.brand_id%>&category_id=<%=@product.category_id%>" class="action_add">添加母商品</a>
    <%  end %>

    |
  <%end%>
  <%= link_to '后退', category_path(@category),:class=>'action_back' -%>
</div>







